package com.openbravo.pos.inventory;

import java.awt.Component;
import java.util.Properties;

import javax.swing.JTabbedPane;

import com.openbravo.bean.erp.OperationCustomer;
import com.openbravo.data.basic.BasicException;
import com.openbravo.data.user.DirtyManager;
import com.openbravo.pos.base.AppLocal;
import com.openbravo.pos.base.AppView;
import com.openbravo.pos.bean.erp.OperationCustomerCategoryExt;
import com.openbravo.pos.inventory.model.OperationCustomerTableModel;

import cn.ekuma.data.dao.I_DataLogic;
import cn.ekuma.data.ui.swing.JChildDAOEditorPanel;
import cn.ekuma.data.ui.swing.SwingEditorRecord;
import cn.ekuma.epos.datalogic.I_DataLogicCustomers;
import cn.ekuma.epos.datalogic.I_DataLogicERP;
import cn.ekuma.epos.module.ERP_UI_Swing_Model;
import cn.ekuma.epos.panel.JPanelTableDAO;

public class OperationCustomerCategoryPanel extends JPanelTableDAO<OperationCustomerCategoryExt> {
    private CategoriesEditor jeditor;
    I_DataLogicERP dlSales ;
	private I_DataLogicCustomers dlCustomers;
   
    
    public OperationCustomerCategoryPanel() {        
    }   
    
    
    protected void init() {   
        dlSales = mode.getDLERP();
        dlCustomers = mode.getDLCustomer();
        jeditor = new CategoriesEditor<OperationCustomerCategoryExt>((AppView) app, dirty,false, dlSales) {
        	JChildDAOEditorPanel productPanel;
        	
        	@Override
            public Class getEditClass() {
                return OperationCustomerCategoryExt.class;
            }

			@Override
			void addChildTabPanel(JTabbedPane tabbedPane) {
				productPanel=new JChildDAOEditorPanel<OperationCustomer>(dlSales,new OperationCustomerTableModel(),new OperationCustomerEditor(dlSales,dlCustomers,new DirtyManager()));
				tabbedPane.add(productPanel.getTabName(),productPanel);
				addObjectChangeListener(productPanel);
			}

			@Override
			public void activate() throws BasicException {
				productPanel.activate();
				super.activate();
			}


			@Override
			public OperationCustomerCategoryExt createNew(Properties prop) {
				return new OperationCustomerCategoryExt();
			}
        };
    }
    
    public SwingEditorRecord getEditor() {
        return jeditor;
    }
    
    public String getTitle() {
        return AppLocal.getIntString("label.operationCustomerCategory");
    }

	@Override
	public Component getFilter() {
		return null;
	}

	@Override
	public I_DataLogic getDataLogic() {
		return dlSales;
	}

	@Override
	public Class getSuportClass() {
		return OperationCustomerCategoryExt.class;
	}

	@Override
	public String getObjectRenderString(OperationCustomerCategoryExt obj) {
		return obj.getName();
	}


	@Override
	public String getModelName() {
		return  ERP_UI_Swing_Model.MODEL_NAME;
	} 
}
